
import React, { Component } from 'react';
import { Table, Pagination } from 'antd';
import styles from './style.less'


class TableComponent extends Component {

    paginationChange = (page, pageSize) => {
        const { paginationChange } = this.props
        paginationChange(page, pageSize)
    }   

    render () {

        // const {
        //     columns,
        //     data,
        //     currentpageSize,
        //     total,
        //     loading
        // } = this.props

        const columns = this.props.columns || []
        const data = this.props.data || []
        const total = this.props.total || 0
        const loading = this.props.loading || false
        const currentpageSize = this.props.currentpageSize || 10
        const rowSelection = this.props.rowSelection || null

        return (
            <>
                <Table
                    rowKey="key"
                    dataSource={data}
                    columns={columns}
                    pagination={false}
                    loading={loading}
                    rowSelection={rowSelection || null}
                >
                </Table>
                <>  
                    <Pagination 
                        style={{
                            float: 'right',
                            marginTop: '10px'
                        }}
                        total={total} 
                        defaultPageSize={currentpageSize}
                        showQuickJumper
                        showSizeChanger
                        onChange = {(page, pageSize) => this.paginationChange(page, pageSize)}
                    />
                </>
            </>
        )
    }

}


// export default TableComponent
export default TableComponent